<template include="./plugin/tt_credits/view/htm/my_credits.template.htm">
	<slot name="my_body"><div class="col-md-6 mx-auto">
		<?php $set=setting_get('tt_credits');$convert = $set['convert_exchange'];?>
		<style>div.tt_card{display:inline-block; width:100%;height:200px;border-radius:5px;background: linear-gradient(to bottom right, #eef6ff , #c8ffff);box-shadow: 0px 5px 10px 0px rgba(0,0,0,0.2);margin-bottom:35px;}
		div.tt_card_s{display:inline-block; width:100%;height:<?php echo $convert==1?'375':'200';?>px;border-radius:5px;background: linear-gradient(to bottom right, #eef6ff , #C8FFFF);box-shadow: 0px 5px 10px 0px rgba(0,0,0,0.2);margin-bottom:35px;}
		div.tt_card_title{margin-top:12px;margin-left:18px;font-size:24px;color:dodgerblue;}
		div.tt_content{margin-top:16px;width:100%;margin-left:24px;margin-right:8px;display:inline-block;}
		</style>
		<div class="tt_card_s"><div class="tt_card_title"><?php echo lang('exchange');?></div>
		<div class="tt_content">支持<span style="color:red"><?php echo lang('credits3');?>(单位:分)</span>，兑换为<span style="color:red"><?php echo lang('credits2');?></span>。<br><form method="post" id="form">
			<input oninput="ONInput(jinput);" onblur="ONInput(jinput);" type="text" id="e_rmb" name="e_rmb" class="form-control" placeholder="<?php echo lang('credits2');?>" style="width: 85%;" maxlength="10"/>可兑换 <span style="color:red;" id="e_golds">0</span><?php echo lang('credits2');?>，需要消耗 ¥ <span style="color:red;" id="show_rmb">0</span><br><button type="button" class="btn btn-info" id="submit" data-loading-text="<?php echo lang('submiting');?>..." data-active="<?php echo url('my-trade');?>" style="right:12%;position:absolute;"><?php echo lang('exchange');?></button></form>
			<?php if($convert==1){ ?><div style="clear:both; margin-top:80px;"></div>
			支持<span style="color:red"><?php echo lang('credits2');?></span>，兑换为<span style="color:red"><?php echo lang('credits3');?>(单位:分)</span>。<br><form method="post" id="form2">
				<input oninput="ONInput2(jinput2);" onblur="ONInput2(jinput2);" type="text" id="e_golds_c" name="e_golds_c"class="form-control" placeholder="<?php echo lang('credits3');?> (分)" maxlength="10" style="width: 85%;"/>可兑换 ¥<span style="color:red;" id="e_rmbs_c">0</span> 元，需要消耗 <span style="color:red;" id="show_golds_c">0</span><?php echo lang('credits2');?><br><button type="button" class="btn btn-info" id="submit2" data-loading-text="<?php echo lang('submiting');?>..." data-active="<?php echo url('my-trade');?>" style="right:12%;position:absolute;"><?php echo lang('exchange');?></button>
				<?php } ?></form></div></div>
		<!--{hook my_trade_after.htm}-->
	</div></slot></template>
<script>
    $('a[data-active="my-trade"]').addClass('active');
</script>
<?php if($convert==1){ ?>
<script>
    var jinput2 = $("#e_golds_c"); var jsubmit2 = $('#submit2'); var jgolds2=$("#e_rmbs_c"); jshow_rmb2 = $("#show_golds_c");
    jsubmit2.on('click', function(){
        jinput2.val(jinput2.val().replace(/[^0-9]/g, ''));
        if(jinput2.val()==''||jinput2.val()=='0') return false;
        $.confirm('您确定要兑换吗?',function(){
            jsubmit2.button('loading');var postdata ="e_golds_c="+jinput2.val()+"&op=c";
            $.xpost(jsubmit2.attr('data-active'), postdata, function(code, message) {
                if(code == 0) {$.alert(message);jsubmit2.button(message).delay(3000).button('reset');
                } else if(code < 0) {$.alert(message);jsubmit2.button('reset');
                } else {alert(message);jsubmit2.button('reset');}
            });
            return false;
        });
    });
    jinput2.bind('input propertychange',function(){
        ONInput2(jinput2);
	});
    function ONInput2(input){
        input.val(input.val().replace(/[^0-9]/g, ''));
        jgolds2.text(input.val()==''?'0':input.val()/100.0);jshow_rmb2.text(input.val()==''?'0':input.val()*parseFloat("<?php echo $set['exchange_c'];?>"));
	}
</script><?php } ?><script>
    var jinput = $("#e_rmb"); var jsubmit = $('#submit'); var jgolds=$("#e_golds"); jshow_rmb = $("#show_rmb");
    jsubmit.on('click', function() {
        if(jinput.val()==""||jinput.val()=="0") return false;
        $.confirm('您确定要兑换吗?',function(){
            jsubmit.button('loading');var postdata = "e_rmb="+jinput.val()+"&op=n";
            $.xpost(jsubmit.attr('data-active'), postdata, function(code, message) {
                if(code == 0) {$.alert(message);jsubmit.button('reset');
                } else if(code < 0) {$.alert(message);jsubmit.button('reset');
                } else {alert(message);jsubmit.button('reset');}});
            return false;
        });
    });
    jinput.bind('input propertychange',function(){
        ONInput(jinput);
    });
	function ONInput(input){
        input.val(input.val().replace(/[^0-9]/g, ''));
        jgolds.text(input.val()==''?'0':input.val());jshow_rmb.text(input.val()==''?'0':input.val()/100.0*parseFloat("<?php echo $set['exchange_n'];?>"));
	}
</script>
<!--{hook my_trade_script_after.htm}-->